home *** CD-ROM | disk | FTP | other *** search
/ boe.pres.k12.wv.us / boe.pres.k12.wv.us.zip / boe.pres.k12.wv.us / Utilities / Xerox Workcentre 5335 / Windows Scan / 64-bit_x64 / Russian / cpsimage.cab / data / sys / XIPRunCallback.elf < prev    next >
Text File  |  2009-04-23  |  5KB  |  127 lines

  1. /* $Id: XIPRunCallback.elf,v 1.1 2008/03/12 16:55:19 campanel Exp $ */
  2.  
  3. /* This file contains script to parse xml that contains a script (either by
  4. ** name or the actual script) and parameters. The script begins near the end
  5. ** of the file. Currently this supports two schemas that define the XML
  6. ** document to parse.
  7. */
  8. #load "sys/xipxml.elf";
  9.  
  10.  
  11. /*****************************************************************************/
  12. /*
  13. ** This class implements the XML serializer and callback for SummonXIP
  14. */
  15. private CLASS XIPRunCallback
  16. {
  17.     METHOD setVocal (BOOLEAN setTo) {
  18.         this.isVocal = setTo;
  19.     }
  20.  
  21.     METHOD appendData( STRING ident, STRING datatype, OBJECT dObj )
  22.     {
  23.         if (this.isVocal == TRUE) {
  24.             print "XIPRunCallback.appendData";
  25.             print "   Data name: "+ident+" has type of "+datatype+". Value is:";
  26.             print dObj;
  27.         }
  28.         this.objs.insert( entry: this.nextIndex, obj: dObj );
  29.         this.ids.insert( entry: this.nextIndex, obj: ident );
  30.         this.dtype.insert( entry: this.nextIndex, obj: datatype );
  31.         this.nextIndex = this.nextIndex+1;
  32.     }
  33.  
  34.     METHOD clearData()
  35.     {
  36.         if (this.isVocal == TRUE) print "XIPRunCallback.ClearData - clearing callback data";
  37.         this.objs.clear();
  38.         this.ids.clear();
  39.         this.dtype.clear();
  40.         this.nextIndex = 0;
  41.     }
  42.  
  43.     METHOD invoke ()
  44.     {
  45.         STRING callXML;
  46.         if (this.isVocal == TRUE) {
  47.             print "XIPRunCallback.invoke";
  48.             print "The value of the callback is ",this.cbFunction;
  49.         }
  50.         callXML = this.makeCallbackXML();
  51.         if (this.callData) this.cInvoke( cData: callXML );
  52.     }
  53.  
  54.     /*****************************************************************************
  55.     ********************    Lots of Private Methods ******************************
  56.     *****************************************************************************/
  57.     private METHOD makeCallbackXML( ) RETURNS ( STRING cbXml ) {
  58.         if (this.isVocal == TRUE) print "XIPRunCallback:makeCallbackXML";
  59.         XmlDocumentBuilder cbdb;
  60.         XmlDocument cbdoc = cbdb.newDocument();
  61.         XmlElement cbroot = cbdoc.createElement( name: "RunXIP" );
  62.         cbdoc.setDocumentElement( node: cbroot );
  63.         XmlElement cbout = cbdoc.createElement( name: "Callback" );
  64.         cbroot.appendChild ( node: cbout );
  65.  
  66.         INTEGER icnt = this.nextIndex;
  67.         INTEGER i;
  68.         STRING rtype;
  69.         STRING cname;
  70.         OBJECT cObj;
  71.         for ( i=0; i<icnt; i++ )
  72.         {
  73.             cname = this.ids.ref( entry: i );
  74.             cObj = this.objs.ref( entry: i );
  75.             rtype = this.dtype.ref( entry: i );
  76.             this.addCallbackValXML( xmlDoc: cbdoc, outEle: cbout,
  77.                                obj: cObj, name: cname, datatype: rtype );
  78.         }
  79.         if (this.isVocal == TRUE) {
  80.             print "Callback Document is:";
  81.             print cbdoc.dumpString( format: 1 );
  82.         }
  83.         cbXml = cbdoc.dumpString( format: 0 );
  84.     }
  85.     
  86.  
  87.     private METHOD addCallbackValXML( XmlDocument xmlDoc, XmlElement outEle, OBJECT obj,
  88.                                  STRING name, STRING datatype )
  89.     {
  90.         XmlAttr rtAttr;
  91.         XmlElement rtelm = xmlDoc.createElement( name: "CallbackVal" );
  92.         XmlElement valName = xmlDoc.createElement( name: "Name" );
  93.         XmlElement valVal = xmlDoc.createElement( name: "Value" );
  94.         STRING objAsStr = obj;
  95.  
  96.         /* Add the ArgType attribute to the ReturnVal element */
  97.         rtAttr = xmlDoc.createAttribute(name: "ArgType");
  98.         rtAttr.setValue( value: datatype );
  99.         rtelm.setAttributeNode( node: rtAttr );
  100.  
  101.         /* Add a child element that contains the Val's name */
  102.         valName.setNodeValue( value: name );
  103.         rtelm.appendChild ( node: valName );
  104.  
  105.         /* Add a child element that contains the actual value */
  106.         valVal.setNodeValue( value: objAsStr );
  107.         rtelm.appendChild ( node: valVal );
  108.  
  109.         /* put the new element (ReturnVal) into the Output element */
  110.         outEle.appendChild ( node: rtelm );
  111.     }
  112.  
  113.  
  114.     private METHOD cInvoke( STRING cData ) NATIVE "SummonXIPCallback@xipsup";
  115.  
  116.     /*****************************************************************************
  117.     ********************    Internal Data Fields    ******************************
  118.     *****************************************************************************/
  119.     STRING callData = "<DefaultReturn></DefaultReturn>";
  120.     BOOLEAN isVocal = FALSE;
  121.     LIST objs;
  122.     LIST ids;
  123.     LIST dtype;
  124.     INTEGER nextIndex = 0;
  125.     VOID cbFunction;
  126. }
  127.